<template>
    <div>
        <div>
            <el-dialog class="nyDialog" :visible.sync="is_dialog_show" width="42%" :close-on-click-modal="false"
                :before-close="() => { this.close(); }">
                <div class="overflow-hidden w-full h-full flex flex-col items-center" style="border-radius:4px;">
                    <div class="w-full h-w48 flex items-center px-w20 justify-between bg-caux text-white">
                        <div class="text-f14">{{ m_data.id ? "编辑问题内容" : "添加问题内容" }}</div>
                        <i class="el-icon-circle-close   cursor-pointer" @click.stop="close()"></i>
                    </div>
                    <div class="w-full flex justify-center">
                        <div class="flex flex-col w-w8/12  ">
                            <div class="flex flex-row items-center  w-full h-w50 leading-w50 text-c3 text-f16  mt-w30">
                                <div class=" w-w1/4 text-right pr-w20">问题内容</div>
                                <el-input class="w-w3/4" placeholder="请输入内容" v-model="m_data.info" clearable autofocus>
                                </el-input>
                            </div>
                        </div>
                    </div>
                    <div class="w-full flex flex-row justify-center mt-w30 mb-w30">
                        <el-button class=" w-w1/5 mr-w20" @click="close">取消</el-button>
                        <el-button class=" w-w1/5 bg-cmain_hover" type="primary" @click="actionSubmit">确定
                        </el-button>
                    </div>
                </div>
            </el-dialog>
        </div>
    </div>
</template>
<script lang="ts">
import nyMessageToast from "@/utils/NYMessageToast";
import DZModelQuestion from "@/views/测评管理/model/DZModelQuestion";
import { Component, Vue, Prop, Watch } from "vue-property-decorator";

@Component
export default class UiDialogAddQuestion extends Vue {

    @Prop() is_showDialog;

    @Prop() data;

    is_dialog_show = false;

    m_data = new DZModelQuestion();


    created() { }

    mounted() {
    }

    beforeDestroy() { }

    close() {
        this.$emit('nydialog_closed', '');
        this.initDialog();
    }
    initDialog() {
        this.m_data = new DZModelQuestion();
        this.is_dialog_show = false;
    }

    @Watch("is_showDialog")
    watchShowDialog(value: any, oldValue: string) {
        this.is_dialog_show = value;
    }
    @Watch("data")
    watchData(value: any, oldValue: string) {
        if (value) {
            this.m_data = value;
        } else {
            this.m_data = new DZModelQuestion();
        }
    }


    actionSubmit() {
        if (this.m_data.info.nyIsEmpty()) {
            nyMessageToast.warning("请输入问题内容");
            return;
        }
        this.$emit('nydialog_submit', this.m_data);
        this.initDialog();
    }
}
</script>
<style lang="less" scoped>
/deep/ .el-dialog {
    border-radius: 4px !important;
    border: none;
}

/deep/.el-dialog__body {
    text-align: left;
    // min-height: 22vw;
    padding: 0px;
}

/deep/ .dialog-tips {
    margin-top: 0 !important;
}

/deep/ .el-dialog__footer {
    text-align: right;
}

/deep/.el-dialog__header {
    height: 0px;
    padding: 0;
}

/deep/ .el-icon-close:before {
    content: '';
}

.nyDialog {
    background: none;
}
</style>
